﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DiarySocial.Models;
using DotNetOpenAuth.Messaging;

namespace DiarySocial.DAL
{
    public class DiaryRepository : GenericRepository<Diary>
    {
        public DiaryRepository(DiaryEnties context) : base(context)
        {
            
        }

        public IEnumerable<int> GetDiaryIdsOfFriends(int userId, int offset, int take)
        {
            var ids = context.GetDiaryIdsOfFriends(userId, offset, take);
            var list = new HashSet<int>(ids.Select(d => d.GetValueOrDefault()));
            return list;
        }

        public IEnumerable<int> GetNewDiaryIdsOfFriends(int userId, int lastId, int maxTake)
        {
            var ids = context.GetNewDiaryIdsOfFriends(userId, lastId, maxTake);
            var list = new HashSet<int>(ids.Select(d => d.GetValueOrDefault()));
            return list;
        }

        public bool UpdateAbout(int userId, string email, string displayName, string job, string school, string address, string introduce)
        {
            return context.UpdateAbout(userId, email, displayName, job, school, address, introduce) == -1;
        }
    }
}